<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="x d cmswrt xsl msxsl" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <xsl:param name="Lang" />
  <xsl:output method="html" indent="no" />

  <!--
	Following Nodes and Attributes are delivered by the conrol

	<MenuItems CurrentKey="[/someUrl]" CurrentLevel="[Number - starts with 0]" Level="[Number - starts with 0]" ParentKey="[/someUrl]">
		<MenuItem ImageUrl="[/someUrl]" Url="[/someUrl]" Target="[|new|_blank]" Title="[someText]" ToolTip="[someText]" Level="[Number - starts with 0]" Selected="[True|False]" Key="[/someUrl]" ParentKey="[/someUrl]">
			<MenuItems>
				<MenuItem ...="">
					...
				</MenuItem>
			</MenuItems>
		</MenuItem>
	</MenuItems>
	-->

  <xsl:variable name="Upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
  <xsl:variable name="Lower" select="'abcdefghijklmnopqrstuvwxyz'"/>

  <xsl:variable name="Text_de-CH" select="'Site Map'" />
  <xsl:variable name="Text_fr-CH" select="'Site Map'" />
  <xsl:variable name="Text_it-CH" select="'Site Map'" />
  <xsl:variable name="Text_en-US" select="'Site Map'" />
  
  <xsl:variable name="CurrentKey" select="translate(//MenuItems/@CurrentKey, $Upper, $Lower)" />
  <xsl:variable name="CurrentLevel" select="//MenuItems/@CurrentLevel" />
  <xsl:variable name="CheckLevel" select="4" />

  <xsl:template match="/">
    <xsl:if test="$CurrentLevel &gt;= 0">
      <div class="hidden"><h1>
          <xsl:choose>
            <xsl:when test="$Lang = 'de-CH' or $Lang = 'de-DE'">
              <xsl:value-of select="$Text_de-CH"/>
            </xsl:when>
            <xsl:when test="$Lang = 'fr-CH'">
              <xsl:value-of select="$Text_fr-CH"/>
            </xsl:when>
            <xsl:when test="$Lang = 'it-CH'">
              <xsl:value-of select="$Text_it-CH"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$Text_en-US"/>
            </xsl:otherwise>
          </xsl:choose>
        </h1></div>
      <div class="content-sitemap">
        <xsl:apply-templates select="MenuItems" />
      </div>
    </xsl:if>
    <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
  </xsl:template>

  <xsl:template match="MenuItems">
    <xsl:if test="$CheckLevel &gt;= @Level">
      <ul>
        <xsl:apply-templates select="MenuItem" />
      </ul>
    </xsl:if>
  </xsl:template>

  <xsl:template match="MenuItem">
    <li>
      <a>
        <xsl:attribute name="href">
          <xsl:value-of select="@Url" />
        </xsl:attribute>
        <xsl:if test="@Target!=''">
	        <xsl:attribute name="target">
	          <xsl:value-of select="@Target" />
	        </xsl:attribute>
        </xsl:if>
        <xsl:attribute name="title">
          <xsl:value-of select="@ToolTip" />
        </xsl:attribute>
        <xsl:value-of select="@Title" />
        <span>
          <xsl:attribute name="class">
            <xsl:text>hidden</xsl:text>
          </xsl:attribute>
          <xsl:value-of select="@ToolTip" />
        </span>
      </a>
      <xsl:apply-templates select="MenuItems" />
    </li>
  </xsl:template>
</xsl:stylesheet>
